package com.linzm.structuraltype.filter03.criteria;

import com.linzm.structuraltype.filter03.Person;

import java.util.List;

/**
 * @Author zimingl
 * @Date 2023/4/16 0:56
 * @Description: AndCriteria
 */
public class AndCriteria implements Criteria {
    private Criteria criteria;
    private Criteria otherCriteria;

    public AndCriteria(Criteria criteria, Criteria otherCriteria) {
        this.criteria = criteria;
        this.otherCriteria = otherCriteria;
    }

    @Override
    public List<Person> meetCriteria(List<Person> persons) {
        List<Person> firstCriteriaPersons = criteria.meetCriteria(persons);
        return otherCriteria.meetCriteria(firstCriteriaPersons);
    }
}
